<style scoped>
    .layui-row {
        overflow: hidden;
    }
    .select-item {
        width: 34.333333%;
        float: right;
    }
    .layui-row:after, .layui-row:before {

    }
    .layui-form >>> .layui-form-select{
        z-index: inherit;
    }
    .layui-table.layui-form div{
        text-align: left;
        padding: 2px 0em 2ex 5%;
    }
    .table_div {
        position: relative;
        left: 150px;
        top: 0px;
        font-size: 17px;
        font-weight:bold  ;
    }
</style>

<template>
    <div class="organization">
        <!-- <table class="layui-table layui-form">

            <thead>
            <tr>
                <th>种植户信息111</th>
                <th>承运人信息</th>
                <th>货品信息</th>
                <th>结算信息</th>
                <th>目的地</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            <tr class="id9" v-for="(val, index) in freightorder" :key="val.guid">
                <td>
                    <div class="table_div">
                        <label>订单编号：</label>
                        <span>{{val.code}}</span>
                    </div>
                    <div>
                        <label>{{val.plantor}}</label>
                        <span>{{val.plantorphone}}</span>
                    </div>
                    <div>
                        <label>{{val.arealand}}</label>

                    </div>
                </td>
                <td>
                    <div class="table_div">
                        <label>{{getTypeName(val.harvest)}}</label>
                    </div>
                    <div>
                        <label>{{val.drivername}}</label>
                        <span>{{val.driverphone}}</span>
                    </div>
                    <div>
                        <label>车牌号:</label>
                        <span>{{val.carcode}}</span>
                    </div>
                </td>
                <td>
                    <div>
                        <label>{{val.createtime}}</label>
                    </div>
                    <div>
                        <label>{{val.variety}}</label>
                        <span>{{val.specification}}</span>
                    </div>
                    <div>
                        <label>单价:</label>
                        <span>{{val.price}}</span>
                    </div>
                </td>
                <td>
                    <div>
                        <label>扣杂率:</label>
                        <label>{{val.deductrate}}</label>
                    </div>
                    <div>
                        <label>扣杂前金额：</label>
                        <span>{{val.damount}}</span>
                    </div>
                    <div>
                        <label>结算金额：</label>
                        <span>{{val.settlement}}</span>
                    </div>
                </td>
                <td>
                    <template v-if="val.harvest == 2">
                        <div>
                            <label>库房:</label>
                            <label>{{val.storeroom}}</label>
                        </div>
                        <div>
                            <label>库间：</label>
                            <span>{{val.storehouse}}</span>
                        </div>
                    </template>
                    <template v-else>
                        <div>
                            <label>省:</label>
                            <label>{{val.provence}}</label>
                        </div>
                        <div>
                            <label>市：</label>
                            <span>{{val.city}}</span>
                        </div>
                        <div>
                            <label>区：</label>
                            <span>{{val.street}}</span>
                        </div>
                    </template>
                </td>


                <td><a href="javascript:;" @click="exportAccept(val.guid)">打印验收单</a> <br/> <a href="javascript:;" @click="exportQaform(val.guid)">打印质检单</a> </td>
            </tr>
            </tbody>
        </table> -->

        <table class="layui-table layui-form">
            <thead>
            <tr>
                <th>货运单编号</th>
                <th>采收工厂</th>
                <th>客户名称</th>
                <th>采收日期</th>
                <th>品种</th>
                <th>规格</th>
                <th>结算重量(吨)</th>

                <th>单价</th>
                <th>扣杂(%)</th>
                <th>结算金额(元)</th>
                <th>订单状态</th>
                <th>支付状态</th>
                <th>入库库房</th>
                <th>入库日期</th>

            </tr>
            </thead>
            <tbody>
            <tr class="id9" v-for="(item, index) in freightorder" :key="item.guid">
                <td>{{item.code}}</td>
                <td>{{item.csgc}}</td>
                <td>{{item.customername}}</td>
                <td>{{item.createtime}}</td>
                <td>{{item.variety}}</td>
                <td>{{item.specification}}</td>
                <td>{{item.settleWeight}}</td>

                <td>{{item.price}}</td>
                <td>{{item.deductRate}}</td>
                <td>{{item.settleAmount}}</td>
                <td>{{item.orderstatus}}</td>
                <td>{{item.paystatusname}}</td>
                <td>{{item.storeroomname}}</td>
                <td>{{item.rcdate}}</td>
            </tr>
            </tbody>
        </table>

        <Pagination :cur="currentPage" :all="totalPage" :callback="turnPage" ></Pagination>
        <div style="height: 200px"></div>

    </div>
</template>

<script>
    import Pagination from '../common/Pagination.vue'
    export default {
        name: 'FreightorderList',
        components: {Pagination},
        props: ['id'],
        data () {
            return {
                guid : this.id,
                organizations: [],
                currentPage: 1,
                totalPage: 0,
                searchName: '',
                batchs:[],
                batchGuid:'',
                freightorder:[]
            }
        },
        updated: function () {
            layui.form.render('select');
            layui.form.render();
        },
        mounted() {
            let that = this;

            layui.use(['form'], function () {
                var form = layui.form,
                    layer = layui.layer;
                that.getPageData();


            });

        },
        methods: {
            search: function() {
                this.getPageData('search');
            },
            turnPage: function(data){
                this.currentPage = data;
                this.getPageData();
            },
            getPageData: function(type = '') {
                let that = this;
                let loader = layui.layer.load();

                let postData = {};

                if (type != 'search') {
                    postData.page = that.currentPage;
                }
                postData.payinfoguid =  that.guid;
                $.ajax({
                    url: '/harvest/Print!getFreightorder.action',
                   // url: '/harvest/Print!getPayInfo.action',
                    type: "post",
                    data: postData,
                    dataType: "json",
                    success: function(res) {
                        if (res != undefined && res.rows != undefined) {
                            //分页数据赋值
                            that.currentPage = res.indexPage;
                            that.totalPage = res.pageCount;
                            that.freightorder = res.rows;

                        } else {
                            that.alert("系统错误");
                        }
                    },
                    complete: function () {
                        layer.close(loader);
                    }
                });
            },
            exportAccept:function (guid){

                window.location.href="/pay/Payinfo!printAcceptForm.action?orderid=" + guid;
            },
            exportQaform:function (guid){

                window.location.href="/pay/Payinfo!printQAForm.action?orderid" + guid;
            },
            /**
             * 查询权限内所有选项的数据
             * @param guid  选择框内选项
             * @param entitys 选择框内所有枚举值
             */
            selectPermisAll:function (guid,entitys,description){
                if(entitys.length == 0){
                    this.toast(description);
                    return false;
                }
                if( guid !=''){
                    return false;
                }
                var srguids = [];
                $.each(entitys, function (index, entity) {
                    srguids.push(entity.guid)
                });
                return srguids.toString();
                },
            getTypeName: function(type) {

                let name = '';
                switch (type) {
                    case '1':
                        name = '采收入库';
                        break;
                    case '2':
                        name = '地头直销';
                        break;

                }
                return name;
            },
            },
    }
</script>
